<HTML>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
	<title>HOSPITAL</title> 
	<link rel="stylesheet" type="text/css" href="style.css" /> 
	<link rel="stylesheet" type="text/css" href="flexigrid-1.1\css\flexigrid.pack.css" /> 
	<script type="text/javascript" src ="jquery-1.5.2.min.js"></script>
	<script src="flexigrid-1.1\js\flexigrid.pack.js" type="text/javascript"></script>
	
</head>
<body>

	<h1><center>Welcome STAFF</center></h1><br/>
	<center><table class="flexme2"></table></center>
	<script type="text/javascript"> 
		$(".flexme2").flexigrid({
			url : 'nurse-db.php',
			dataType : 'json',
			colModel : [ {
				display : 'STAFF_ID',
				name : 'STF_ID',
				width : 100,
				sortable : true,
				align : 'center'
			}, {
				display : 'First name',
				name : 'F_NAME',
				width : 100,
				sortable : true,
				align : 'left'
			}, {
				display : 'Last name',
				name : 'L_NAME',
				width : 120,
				sortable : true,
				align : 'left'
			}, {
				display : 'JOB_TYPE',
				name : 'JOB_TYPE',
				width : 60,
				sortable : true,
				align : 'center'
			}, {
				display : 'SALARY',
				name : 'SALARY',
				width : 80,
				sortable : true,
				align : 'left'
			}, {
				display : 'START_CONTRACT',
				name : 'START_CONTRACT',
				width : 80,
				sortable : true,
				align : 'center'
			}, {
				display : 'END_CONTRACT',
				name : 'END_CONTRACT',
				width : 80,
				sortable : true,
				align : 'center'
			},],
			buttons : [ {
				name : 'Add',
				bclass : 'add',
				onpress : test
			}, {
				name : 'Delete',
				bclass : 'delete',
				onpress : test
			}, {
				name : 'Edit',
				bclass : 'edit',
				onpress : test
			},{
				separator : true
			} ],
			searchitems : [ {
				display : 'ISO',
				name : 'iso'
			}, {
				display : 'Name',
				name : 'name',
				isdefault : true
			} ],
			sortname : "STF_ID",
			sortorder : "asc",
			usepager : true,
			title : 'STAFF',
			useRp : true,
			rp : 15,
			showTableToggleBtn : true,
			width : 680,
			height : 200
		});
		function test(com, grid) {
			if (com == 'Add') {
                                var str = "nurse";
				window.location = "http://localhost/hospital/form-add-nurse.html?page="+str;
			} else if (com == 'Delete') {
				$('.trSelected', grid).each(
					function() {
						var id = $(this).attr('id');
						id = id.substring(id.lastIndexOf('row')+3);
						if(confirm('Delete ' + $('.trSelected', grid).length + ' items? staff_id no.'+id)==true){
							window.location = "http://localhost/hospital/delete-nurses.php?id="+id;
							
						}
						false;
					});
			} else if (com == 'Edit'){
				$('.trSelected', grid).each(
					function() {
						var id = $(this).attr('id');
						id = id.substring(id.lastIndexOf('row')+3);
						if(confirm('Update ' + $('.trSelected', grid).length + ' items? id no.'+id)==true){
							window.location = "http://localhost/hospital/form-edit-nurse.php?ids="+id;
						}
						false;
					});

			}
		}
	</script>
	
</body>
</HTML>
